using System.Threading;

namespace MyUtility.Singleton
{
    public abstract class BaseCancelTokenSingleton<T> : BaseSingleton<T> where T : class, new()
    {
        public CancellationToken Token => CancelSource.Token;
        public CancellationTokenSource CancelSource
        {
            get
            {
                if(_cancelSource == null || _cancelSource.IsCancellationRequested)
                    _cancelSource = new CancellationTokenSource();
                return _cancelSource;
            }
        }
        
        private CancellationTokenSource _cancelSource;
    }
}